<?php
/**
 + Created by:	Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webitsolution.com , info@webitsolution.com
			www.wrecruit.com, developer@wrecruit.com
 * Created on:	Oct 5, 2012
 ^
 + Project: 		WRecruit 
 * File Name:	module/topwrecruit.php
 ^ 
 * Description: Module for WRecruit
 ^ 
 * History:		1.0.2 - Mar 21, 2012
 ^ 
 */

defined('_JEXEC') or die('Restricted access');

$noofjobs = $params->get('noofjobs', 7);
$category = $params->get('category', 1);
$company = $params->get('company', 1);
$jobtype = $params->get('jobtype', 1);
$posteddate = $params->get('posteddate', 1);
$theme = $params->get('theme', 1);
$separator = $params->get('separator', 1);
$colperrow = $params->get('colperrow',3);
//scs
$sliding= $params->get('sliding','1');
$consecutivesliding= $params->get('consecutivesliding','3');
$slidingdirection= $params->get('slidingdirection','1'); // 0 = left  , 1=up
//sce

$colwidth = Round(100/$colperrow,1);
$colwidth = $colwidth.'%';
$colcount = 1;

/** scs */
if($params->get('Itemid')) $itemid = $params->get('Itemid');			
else $itemid =  JRequest::getVar('Itemid');

$componentAdminPath = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_wrecruit';
$componentPath =  'components' . DS . 'com_wrecruit';
require_once $componentPath . DS . 'models' . DS . 'mpwrecruit.php';
$config = array( 'table_path' => $componentAdminPath . DS . 'tables');
$model = new WRecruitModelMpWRecruit($config);

$result = $model->getTopJobs($noofjobs,$theme);
$jobs = $result[0];
$trclass = $result[1];	
$dateformat = $result[2];	
$contents ='';
/** sce */
if ($jobs) { 
    $contents .=  '<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane">';
	$isodd = 1;
	foreach ($jobs as $job) {
	    $isodd = 1 - $isodd;
		$contents .=  '<tr  class="'.$trclass[$isodd].'">'; $contents .= '<td  width="'.$colwidth.'">';
			 $contents .=  '<a href="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=view_job&vj=2&oi=' . $job->id . '&Itemid='.$itemid.'"><u><strong>'
	        . $job->title . '</strong></u></a></td>';
		if ($company == 1) {  if($colcount == $colperrow){ $contents .=  '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
				$contents .= '<td  width="'.$colwidth.'">';  $contents .=  '<small>'.JText::_('JS_COMPANY').': <a href="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=view_company&vm=5&md=' .$job->companyid . '&Itemid='.$itemid.'">'.$job->companyname.'</a></small></td>';	
		}if ($category == 1) {  if($colcount == $colperrow){ $contents .=  '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td  width="'.$colwidth.'">';   $contents .=  '<small>'.JText::_('JS_CATEGORY').': '.$job->cat_title.'</small></td>';	
		}if ($jobtype == 1) {  if($colcount == $colperrow){ $contents .=  '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td  width="'.$colwidth.'">';  $contents .=   '<small>'.JText::_('JS_TYPE').': '.$job->jobtypetitle.'</small></td>';	
		}if ($posteddate == 1) {  if($colcount == $colperrow){ $contents .=  '</tr><tr class="'.$trclass[$isodd].'" >'; $colcount = 0; } $colcount++; 
			$contents .= '<td  width="'.$colwidth.'">'; $contents .=   "<small>".JText::_('JS_POSTED').": ".date($dateformat,strtotime($job->created))."</small></td>";
		}
		if ($separator == 1) {  if($colcount == $colperrow){ $contents .=  '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td  width="'.$colwidth.'">';  $contents .=  '<hr style="border:dashed #C0C0C0; border-width:1px 0 0 0; height:0;line-height:0px;font-size:0;margin:0;padding:0;"></td>';
		}
		for($i = $colcount; $i < $colperrow; $i++){
			$contents .=  '<td></td>';
		}
		$contents .=  '</tr>';
		$colcount=1;
    }
	$contents .=  '</table>';
	if ($sliding == 1) {
		
		if($slidingdirection == 1 ){
			for ($a = 0; $a < $consecutivesliding; $a++){
				$contents .= $contents;
				}
			$contents =  '<marquee  direction="up" scrollamount="2" onmouseover="this.stop();" onmouseout="this.start()";>'.$contents.'</marquee>';
			$contents = $contents.'<br clear="all">';
		}else{
			
			$tcontents = '<table cellpadding="0" cellspacing="0" border="1" width="100%" class="contentpane"> <tr>';
			for ($a = 0; $a < $consecutivesliding; $a++){
				$scontents = '<td>'.$contents.'</td>';
			}
			$contents = $tcontents.$scontents.'</tr></table>';
			$contents =  '<marquee  scrollamount="2" onmouseover="this.stop();" onmouseout="this.start()";>'.$contents.'</marquee>';
		}
	}
	
	echo $contents;
	
}
?>

